package com.yzcrm.erp.crm.common;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Flowers bloom all over the ground, frequent urination urination not enough!
 * IDE: Created with by IntelliJ IDEA.
 * program: yzcrm
 *
 * @author :jones
 * github: https://github.com/luckyrxp
 * email: jonesxr@163.com
 * version: v 1.0
 *
 * <p>
 * <p>
 * date: 2020-08-19
 * time: 16:46
 * description:报价组合 controller
 * Copyright(©) 2020 by Jones
 **/
public enum QuotationCombEnum {
    /**
     * 正常数据 1.
     */
    AVAILABLE(1, "正常数据"),

    /**
     * 逻辑删除 2.
     */
    DELETE(2, "逻辑删除"),

    /**
     * 分隔符 “,”
     */
    COMMA(3, ","),

    /**
     * 税率 目前固定 13%
     */
    RATE(13, "税率"),

    /**
     * 1 新增
     */
    ADD(0, "新增"),

    /**
     * 1 硬件
     */
    ITEM_OPTION_HARDWARE(1, "硬件"),
    /**
     * 2 授权
     */
    ITEM_OPTION_AUTH(2, "CNC授权"),
    /**
     * 3 本地部署授权
     */
    ITEM_OPTION_LOCAL_DEPLOY_AUTH(3, "本地部署授权"),
    /**
     * 4 年费
     */
    ITEM_OPTION_ANNUAL_FEE(4, "年费"),
    /**
     * 5 人工
     */
    ITEM_OPTION_ARTIFICIAL(5, "人工"),
    /**
     * 合计价格低于总监价格/增值税率低于6%或13%
     */
    MORE_THAN_PRICE_VAT_RATE(1, "销售单价小于总监单价，不低于13%"),
    /**
     * 合计价格高于总监价格/增值税率高于6%或13%
     */
    LESS_THAN_PRICE_VAT_RATE(2, "销售单价大于总监单价，低于13%"),
    /**
     * 0 未审核
     */
    UNREVIEWED(0, "未审核"),
    /**
     * 1 审核通过
     */
    EXAMINATION_PASSED(1, "审核通过"),
    /**
     * 2 审核拒绝
     */
    REVIEW_REJECTED(2, "审核拒绝"),
    /**
     * 3 审核中
     */
    UNDER_REVIEW(3, "审核中"),
    /**
     * 4 已撤回
     */
    WITHDRAWN(4, "已撤回"),
    /**
     * 5 草稿
     */
    SAVE_TO_DRAFT(5, "草稿"),
    /**
     * 6 作废
     */
    INVALID(6, "作废"),
    /**
     * 查询
     */
    FIND_BY_ID(1, "SELECT quotation_id as 'quotationId'," +
            "quotation_item_id as 'quotationItemId',check_status AS 'rs'," +
            "owner_user_id 'oui',examine_record_id 'eri' " +
            "FROM `yzcrm_crm_quotation_combination` " +
            "WHERE quotation_id = ?"),
    /**
     * 1 有权查看(总监价格查看)
     */
    HAVE(1, "有"),
    /**
     * 2 无权查看(总监价格查看)
     */
    NO(2, "无"),
    /**
     * 产品选项
     */
    FIND_QUOTATION_ITEM(1, "SELECT option_key AS 'id',option_value AS 'name' FROM `yzcrm_crm_quotation_template` WHERE flag = 1 AND del_flog = 1"),
    /**
     * 部署方式
     */
    FIND_DEPLOY_MODE(2, "SELECT deploy_key AS 'id',deploy_value AS 'name' FROM `yzcrm_crm_quotation_template` WHERE flag = 2 AND del_flog = 1"),
    /**
     * 增值税
     */
    FIND_VAT_RATE(3, "SELECT rate_key AS 'id',rate_value AS 'name' FROM `yzcrm_crm_quotation_template` WHERE flag = 3 AND del_flog = 1"),
    /**
     * 1 语祯云公有部署
     */
    PUBLIC_DEPLOY(1, "语祯云公有部署"),
    /**
     * 2 语祯云本地部署
     */
    LOCAL_DEPLOY(2, "语祯云本地部署"),

    /**
     * 部署方式 id
     */
    QUOTATION_ITEM_ID(3, "quotation_item_id"),

    /**
     * 字段定义
     */
    ITEM_OPTION(1, "itemOption"),
    RS(2, "rs"),
    OUI(3, "oui"),
    ERI(4, "eri"),
    STATUS(5, "status"),
    ;


    /**
     * 代码.
     */
    final int code;
    /**
     * 名称.
     */
    final String name;

    /**
     * Constructor.
     */
    QuotationCombEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    private static final Map<String, QuotationCombEnum> ITEM_MAP;

    static {
        final Map<String, QuotationCombEnum> map = new HashMap<>();
        for (QuotationCombEnum type : QuotationCombEnum.values()) {
            map.put(String.valueOf(type.getCode()), type);
        }

        ITEM_MAP = Collections.unmodifiableMap(map);
    }

    /**
     * 取得对应的 名称.
     *
     * @param code 代码.
     * @return 名称.
     */
    public static String lookupName(final String code) {
        if (ITEM_MAP.containsKey(code)) {
            return ITEM_MAP.get(code).getName();
        } else {
            return "";
        }
    }

}
